﻿namespace SERFLITEMAX20.Viewer
{
    using PJLControls;
    using SERFLITEMAX20;
    using SERFLITEMAX20.DataObjects;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class frmOptions : Form
    {
        private ToolStripMenuItem assignToGroupToolStripMenuItem;
        private Button btnAddHighlight;
        private Button btnCancel;
        private Button btnCreateGroup;
        private Button btnDeleteGroup;
        private Button btnDeleteHighlight;
        private Button btnFindFilter;
        private Button btnFindFocusTarget;
        private Button btnOK;
        private Button btnRefreshFilters;
        private Button btnRefreshFocusTargets;
        private Button btnSaveFilters;
        private Button btnSelectGroup;
        private ComboBox cbDisplayText;
        private ComboBox cboDeleteGroups;
        private ComboBox cbogroups;
        private CheckBox cbShowMinimap;
        private CheckBox cbStayOnTop;
        private ComboBox cbVisible;
        private CheckBox cbxFilter;
        private CheckBox cbxRotateMap;
        private ColumnHeader chColor;
        private ColumnHeader chDisplay;
        private CheckBox chkShowHideGroups;
        private ColumnHeader chName;
        private ColumnHeader chVisible;
        private ToolStripMenuItem clearAllFilteredToolStripMenuItem;
        private ToolStripMenuItem clearSpecialToolStripMenuItem;
        private ColumnHeader columnHeader1;
        private ColumnHeader columnHeader2;
        private ColumnHeader columnHeader3;
        private ColumnHeader columnHeader4;
        private ColumnHeader columnHeader5;
        private ColumnHeader columnHeader6;
        private IContainer components;
        private ContextMenuStrip contextMenuStrip1;
        private ColorPicker cpColor;
        private clsDisplayItem diSelected = null;
        private Label label1;
        private Label label2;
        private Label label7;
        private ListView lstViewObjects;
        private ListViewItem lviSelected = null;
        private long mFocusGuid = 0L;
        private bool mInUpdate = false;
        private ListViewSortManager mListViewSortManager = null;
        private ViewMain mMain = null;
        private NumericUpDown nudMinimapRadius;
        private Panel panel1;
        private Panel panel2;
        private Panel panel3;
        private Panel panel4;
        private ToolStripMenuItem setFIlteredToolStripMenuItem;
        private ToolStripMenuItem setSpecialToolStripMenuItem;
        private SharpListView.SharpListView slvHighlights;
        private TabPage tbFilter;
        private TabPage tbFocus;
        private TextBox tbName;
        private TextBox tbPort;
        private TextBox tbServer;
        private TabControl tcOptions;
        private TabPage tpGeneral;
        private TabPage tpHighlights;
        private TreeView treeView1;
        private TextBox txtFilterQuery;
        private TextBox txtFocustTargetQuery;
        private TextBox txtGroupname;

        public frmOptions()
        {
            this.InitializeComponent();
        }

        private void btnAddHighlight_Click(object sender, EventArgs e)
        {
            int num = 1;
            foreach (ListViewItem item in this.slvHighlights.Items)
            {
                if (item.SubItems[3].Text.StartsWith("Custom Highlight #"))
                {
                    num++;
                }
                item.Selected = false;
            }
            this.diSelected = new clsDisplayItem(true, eDisplayText.Nothing, "Custom Highlight #" + num.ToString(), Color.Black.ToArgb());
            this.lviSelected = new ListViewItem();
            this.lviSelected.SubItems[0].Text = Color.Black.ToArgb().ToString();
            this.lviSelected.SubItems.Add("Yes");
            this.lviSelected.SubItems.Add("Nothing");
            this.lviSelected.SubItems.Add(this.diSelected.Name);
            this.lviSelected.Tag = this.diSelected;
            this.lviSelected.Selected = true;
            this.slvHighlights.Items.Add(this.lviSelected);
        }

        private void btnDeleteGroup_Click(object sender, EventArgs e)
        {
            if (this.cboDeleteGroups.SelectedItem != null)
            {
                ListViewGroup group = this.lstViewObjects.Groups[(string) this.cboDeleteGroups.SelectedItem];
                if (group != null)
                {
                    foreach (ListViewItem item in this.lstViewObjects.Items)
                    {
                        if (item.Group == group)
                        {
                            item.Group = null;
                            FilterObject obj2 = Support.filterObjectList[(string) item.Tag];
                            if (obj2.typeid.Length > 0)
                            {
                                obj2.group = obj2.typeid;
                            }
                            else
                            {
                                obj2.group = "General";
                            }
                        }
                    }
                    this.lstViewObjects.Groups.Remove(group);
                }
            }
        }

        private void btnDeleteHighlight_Click(object sender, EventArgs e)
        {
            if (((this.diSelected != null) && (this.lviSelected != null)) && (!this.diSelected.Name.StartsWith("[") || !this.diSelected.Name.EndsWith("]")))
            {
                this.slvHighlights.Items.Remove(this.lviSelected);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
        }

        private void btnSelectGroup_Click(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.LoadFocused();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.LoadFilters();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Support.SaveFilterObjectList();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.FindFilter();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            string key = this.txtGroupname.Text.Trim();
            if ((key.Length > 0) || (this.lstViewObjects.Groups[key] == null))
            {
                this.lstViewObjects.Groups.Add(key, key);
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            this.FindFocused();
        }

        private void cbDisplayText_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.diSelected != null)
            {
                this.diSelected.DisplayText = (eDisplayText) this.cbDisplayText.SelectedIndex;
                switch (this.diSelected.DisplayText)
                {
                    case eDisplayText.Nothing:
                        this.lviSelected.SubItems[2].Text = "Nothing";
                        break;

                    case eDisplayText.OnlyName:
                        this.lviSelected.SubItems[2].Text = "Name";
                        break;

                    case eDisplayText.OnlyLevel:
                        this.lviSelected.SubItems[2].Text = "Level";
                        break;

                    case eDisplayText.BothNameAndLevel:
                        this.lviSelected.SubItems[2].Text = "Name+Level";
                        break;

                    case eDisplayText.RaceAndClass:
                        this.lviSelected.SubItems[2].Text = "Race+Class";
                        break;

                    case eDisplayText.RaceAndClassAndLevel:
                        this.lviSelected.SubItems[2].Text = "Race+Class+Level";
                        break;

                    case eDisplayText.Find:
                        this.lviSelected.SubItems[2].Text = "Find";
                        break;
                }
            }
        }

        private void cboDeleteGroups_DropDown(object sender, EventArgs e)
        {
            this.cboDeleteGroups.Items.Clear();
            foreach (ListViewGroup group in this.lstViewObjects.Groups)
            {
                this.cboDeleteGroups.Items.Add(group.Name);
            }
        }

        private void cbogroups_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        private void cbVisible_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.diSelected != null)
            {
                this.diSelected.Visible = this.cbVisible.SelectedIndex == 0;
                this.lviSelected.SubItems[1].Text = this.diSelected.Visible ? "Yes" : "No";
            }
        }

        private void chkShowHideGroups_CheckedChanged(object sender, EventArgs e)
        {
            this.LoadFilters();
        }

        private void clearAllFilteredToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in this.lstViewObjects.SelectedItems)
            {
                string tag = (string) item.Tag;
                item.SubItems[4].Text = false.ToString();
                Support.filterObjectList[tag].filtered = false;
                if (Support.filterObjectList[tag].special)
                {
                    item.ForeColor = Color.Green;
                }
                else
                {
                    item.ForeColor = SystemColors.WindowText;
                }
            }
        }

        private void clearSpecialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in this.lstViewObjects.SelectedItems)
            {
                string tag = (string) item.Tag;
                item.SubItems[5].Text = false.ToString();
                Support.filterObjectList[tag].special = false;
                if (!Support.filterObjectList[tag].filtered)
                {
                    item.ForeColor = SystemColors.WindowText;
                }
            }
        }

        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            this.assignToGroupToolStripMenuItem.DropDownItems.Clear();
            foreach (ListViewGroup group in this.lstViewObjects.Groups)
            {
                this.assignToGroupToolStripMenuItem.DropDownItems.Add(group.Name, null, new EventHandler(this.OnGroupMenueClick)).Tag = group;
            }
        }

        private void cpColor_ColorChanged(object sender, ColorChangedEventArgs e)
        {
            if (this.diSelected != null)
            {
                this.diSelected.Color = this.cpColor.Color.ToArgb();
                this.lviSelected.SubItems[0].Text = this.diSelected.Color.ToString();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FindFilter()
        {
            this.LoadFilters();
            string text = this.txtFilterQuery.Text;
            foreach (ListViewItem item in this.lstViewObjects.Items)
            {
                if (((item.SubItems[1].Text.IndexOf(text) == -1) && (item.SubItems[2].Text.IndexOf(text) == -1)) && (item.SubItems[3].Text.IndexOf(text) == -1))
                {
                    item.Remove();
                }
            }
        }

        private void FindFocused()
        {
            this.LoadFocused();
            string text = this.txtFilterQuery.Text;
            foreach (TreeNode node in this.treeView1.Nodes)
            {
                foreach (TreeNode node2 in node.Nodes)
                {
                    if (node2.Text.IndexOf(text) == -1)
                    {
                        node2.Remove();
                    }
                }
            }
        }

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.panel1 = new System.Windows.Forms.Panel();
            this.btnCancel = new System.Windows.Forms.Button();
            this.btnOK = new System.Windows.Forms.Button();
            this.tbFilter = new System.Windows.Forms.TabPage();
            this.cboDeleteGroups = new System.Windows.Forms.ComboBox();
            this.btnDeleteGroup = new System.Windows.Forms.Button();
            this.btnSelectGroup = new System.Windows.Forms.Button();
            this.cbogroups = new System.Windows.Forms.ComboBox();
            this.chkShowHideGroups = new System.Windows.Forms.CheckBox();
            this.txtGroupname = new System.Windows.Forms.TextBox();
            this.btnCreateGroup = new System.Windows.Forms.Button();
            this.txtFilterQuery = new System.Windows.Forms.TextBox();
            this.btnFindFilter = new System.Windows.Forms.Button();
            this.btnSaveFilters = new System.Windows.Forms.Button();
            this.btnRefreshFilters = new System.Windows.Forms.Button();
            this.lstViewObjects = new System.Windows.Forms.ListView();
            this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.setFIlteredToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.setSpecialToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.clearAllFilteredToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.clearSpecialToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.assignToGroupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.tpHighlights = new System.Windows.Forms.TabPage();
            this.slvHighlights = new SharpListView.SharpListView();
            this.chColor = new System.Windows.Forms.ColumnHeader();
            this.chVisible = new System.Windows.Forms.ColumnHeader();
            this.chDisplay = new System.Windows.Forms.ColumnHeader();
            this.chName = new System.Windows.Forms.ColumnHeader();
            this.panel4 = new System.Windows.Forms.Panel();
            this.btnDeleteHighlight = new System.Windows.Forms.Button();
            this.btnAddHighlight = new System.Windows.Forms.Button();
            this.panel3 = new System.Windows.Forms.Panel();
            this.tbName = new System.Windows.Forms.TextBox();
            this.cbDisplayText = new System.Windows.Forms.ComboBox();
            this.cbVisible = new System.Windows.Forms.ComboBox();
            this.cpColor = new PJLControls.ColorPicker();
            this.tpGeneral = new System.Windows.Forms.TabPage();
            this.nudMinimapRadius = new System.Windows.Forms.NumericUpDown();
            this.label7 = new System.Windows.Forms.Label();
            this.cbShowMinimap = new System.Windows.Forms.CheckBox();
            this.cbStayOnTop = new System.Windows.Forms.CheckBox();
            this.panel2 = new System.Windows.Forms.Panel();
            this.tbPort = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.tbServer = new System.Windows.Forms.TextBox();
            this.cbxFilter = new System.Windows.Forms.CheckBox();
            this.cbxRotateMap = new System.Windows.Forms.CheckBox();
            this.tcOptions = new System.Windows.Forms.TabControl();
            this.tbFocus = new System.Windows.Forms.TabPage();
            this.txtFocustTargetQuery = new System.Windows.Forms.TextBox();
            this.btnFindFocusTarget = new System.Windows.Forms.Button();
            this.btnRefreshFocusTargets = new System.Windows.Forms.Button();
            this.treeView1 = new System.Windows.Forms.TreeView();
            this.panel1.SuspendLayout();
            this.tbFilter.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            this.tpHighlights.SuspendLayout();
            this.panel4.SuspendLayout();
            this.panel3.SuspendLayout();
            this.tpGeneral.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.nudMinimapRadius)).BeginInit();
            this.tcOptions.SuspendLayout();
            this.tbFocus.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.btnCancel);
            this.panel1.Controls.Add(this.btnOK);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel1.Location = new System.Drawing.Point(0, 351);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(713, 32);
            this.panel1.TabIndex = 5;
            // 
            // btnCancel
            // 
            this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Location = new System.Drawing.Point(626, 6);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(75, 23);
            this.btnCancel.TabIndex = 1;
            this.btnCancel.Text = "Cancel";
            // 
            // btnOK
            // 
            this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.btnOK.Location = new System.Drawing.Point(545, 6);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(75, 23);
            this.btnOK.TabIndex = 0;
            this.btnOK.Text = "OK";
            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
            // 
            // tbFilter
            // 
            this.tbFilter.Controls.Add(this.cboDeleteGroups);
            this.tbFilter.Controls.Add(this.btnDeleteGroup);
            this.tbFilter.Controls.Add(this.btnSelectGroup);
            this.tbFilter.Controls.Add(this.cbogroups);
            this.tbFilter.Controls.Add(this.chkShowHideGroups);
            this.tbFilter.Controls.Add(this.txtGroupname);
            this.tbFilter.Controls.Add(this.btnCreateGroup);
            this.tbFilter.Controls.Add(this.txtFilterQuery);
            this.tbFilter.Controls.Add(this.btnFindFilter);
            this.tbFilter.Controls.Add(this.btnSaveFilters);
            this.tbFilter.Controls.Add(this.btnRefreshFilters);
            this.tbFilter.Controls.Add(this.lstViewObjects);
            this.tbFilter.Location = new System.Drawing.Point(4, 22);
            this.tbFilter.Name = "tbFilter";
            this.tbFilter.Padding = new System.Windows.Forms.Padding(3);
            this.tbFilter.Size = new System.Drawing.Size(693, 323);
            this.tbFilter.TabIndex = 6;
            this.tbFilter.Text = "Filter";
            this.tbFilter.UseVisualStyleBackColor = true;
            // 
            // cboDeleteGroups
            // 
            this.cboDeleteGroups.FormattingEnabled = true;
            this.cboDeleteGroups.Location = new System.Drawing.Point(428, 32);
            this.cboDeleteGroups.Name = "cboDeleteGroups";
            this.cboDeleteGroups.Size = new System.Drawing.Size(142, 21);
            this.cboDeleteGroups.TabIndex = 13;
            this.cboDeleteGroups.DropDown += new System.EventHandler(this.cboDeleteGroups_DropDown);
            // 
            // btnDeleteGroup
            // 
            this.btnDeleteGroup.Location = new System.Drawing.Point(576, 33);
            this.btnDeleteGroup.Name = "btnDeleteGroup";
            this.btnDeleteGroup.Size = new System.Drawing.Size(111, 20);
            this.btnDeleteGroup.TabIndex = 12;
            this.btnDeleteGroup.Text = "Remove Group";
            this.btnDeleteGroup.UseVisualStyleBackColor = true;
            this.btnDeleteGroup.Click += new System.EventHandler(this.btnDeleteGroup_Click);
            // 
            // btnSelectGroup
            // 
            this.btnSelectGroup.Location = new System.Drawing.Point(334, 35);
            this.btnSelectGroup.Name = "btnSelectGroup";
            this.btnSelectGroup.Size = new System.Drawing.Size(79, 20);
            this.btnSelectGroup.TabIndex = 11;
            this.btnSelectGroup.Text = "Show";
            this.btnSelectGroup.UseVisualStyleBackColor = true;
            this.btnSelectGroup.Click += new System.EventHandler(this.btnSelectGroup_Click);
            // 
            // cbogroups
            // 
            this.cbogroups.FormattingEnabled = true;
            this.cbogroups.Location = new System.Drawing.Point(185, 34);
            this.cbogroups.Name = "cbogroups";
            this.cbogroups.Size = new System.Drawing.Size(142, 21);
            this.cbogroups.TabIndex = 10;
            this.cbogroups.SelectedIndexChanged += new System.EventHandler(this.cbogroups_SelectedIndexChanged);
            // 
            // chkShowHideGroups
            // 
            this.chkShowHideGroups.AutoSize = true;
            this.chkShowHideGroups.Checked = true;
            this.chkShowHideGroups.CheckState = System.Windows.Forms.CheckState.Checked;
            this.chkShowHideGroups.Location = new System.Drawing.Point(586, 10);
            this.chkShowHideGroups.Name = "chkShowHideGroups";
            this.chkShowHideGroups.Size = new System.Drawing.Size(117, 17);
            this.chkShowHideGroups.TabIndex = 9;
            this.chkShowHideGroups.Text = "Show/Hide Groups";
            this.chkShowHideGroups.UseVisualStyleBackColor = true;
            this.chkShowHideGroups.CheckedChanged += new System.EventHandler(this.chkShowHideGroups_CheckedChanged);
            // 
            // txtGroupname
            // 
            this.txtGroupname.Location = new System.Drawing.Point(419, 6);
            this.txtGroupname.Name = "txtGroupname";
            this.txtGroupname.Size = new System.Drawing.Size(80, 20);
            this.txtGroupname.TabIndex = 8;
            // 
            // btnCreateGroup
            // 
            this.btnCreateGroup.Location = new System.Drawing.Point(501, 9);
            this.btnCreateGroup.Name = "btnCreateGroup";
            this.btnCreateGroup.Size = new System.Drawing.Size(79, 20);
            this.btnCreateGroup.TabIndex = 7;
            this.btnCreateGroup.Text = "Create Group";
            this.btnCreateGroup.UseVisualStyleBackColor = true;
            this.btnCreateGroup.Click += new System.EventHandler(this.button5_Click);
            // 
            // txtFilterQuery
            // 
            this.txtFilterQuery.Location = new System.Drawing.Point(184, 9);
            this.txtFilterQuery.Name = "txtFilterQuery";
            this.txtFilterQuery.Size = new System.Drawing.Size(144, 20);
            this.txtFilterQuery.TabIndex = 6;
            this.txtFilterQuery.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp);
            // 
            // btnFindFilter
            // 
            this.btnFindFilter.Location = new System.Drawing.Point(334, 8);
            this.btnFindFilter.Name = "btnFindFilter";
            this.btnFindFilter.Size = new System.Drawing.Size(79, 20);
            this.btnFindFilter.TabIndex = 5;
            this.btnFindFilter.Text = "Find";
            this.btnFindFilter.UseVisualStyleBackColor = true;
            this.btnFindFilter.Click += new System.EventHandler(this.button4_Click);
            // 
            // btnSaveFilters
            // 
            this.btnSaveFilters.Location = new System.Drawing.Point(103, 6);
            this.btnSaveFilters.Name = "btnSaveFilters";
            this.btnSaveFilters.Size = new System.Drawing.Size(75, 23);
            this.btnSaveFilters.TabIndex = 4;
            this.btnSaveFilters.Text = "Save";
            this.btnSaveFilters.Click += new System.EventHandler(this.button3_Click);
            // 
            // btnRefreshFilters
            // 
            this.btnRefreshFilters.Location = new System.Drawing.Point(8, 6);
            this.btnRefreshFilters.Name = "btnRefreshFilters";
            this.btnRefreshFilters.Size = new System.Drawing.Size(75, 23);
            this.btnRefreshFilters.TabIndex = 3;
            this.btnRefreshFilters.Text = "Refresh";
            this.btnRefreshFilters.Click += new System.EventHandler(this.button2_Click);
            // 
            // lstViewObjects
            // 
            this.lstViewObjects.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.lstViewObjects.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader4,
            this.columnHeader1,
            this.columnHeader2,
            this.columnHeader3,
            this.columnHeader5,
            this.columnHeader6});
            this.lstViewObjects.ContextMenuStrip = this.contextMenuStrip1;
            this.lstViewObjects.FullRowSelect = true;
            this.lstViewObjects.HideSelection = false;
            this.lstViewObjects.Location = new System.Drawing.Point(3, 57);
            this.lstViewObjects.Name = "lstViewObjects";
            this.lstViewObjects.Size = new System.Drawing.Size(684, 260);
            this.lstViewObjects.TabIndex = 0;
            this.lstViewObjects.UseCompatibleStateImageBehavior = false;
            this.lstViewObjects.View = System.Windows.Forms.View.Details;
            this.lstViewObjects.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.lstViewObjects_ItemChecked);
            this.lstViewObjects.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lstViewObjects_KeyDown);
            // 
            // columnHeader4
            // 
            this.columnHeader4.Text = "Entry";
            this.columnHeader4.Width = 128;
            // 
            // columnHeader1
            // 
            this.columnHeader1.Text = "Name";
            this.columnHeader1.Width = 98;
            // 
            // columnHeader2
            // 
            this.columnHeader2.Text = "Type";
            this.columnHeader2.Width = 98;
            // 
            // columnHeader3
            // 
            this.columnHeader3.Text = "TypeID";
            this.columnHeader3.Width = 107;
            // 
            // columnHeader5
            // 
            this.columnHeader5.Text = "filtered";
            // 
            // columnHeader6
            // 
            this.columnHeader6.Text = "special";
            // 
            // contextMenuStrip1
            // 
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.setFIlteredToolStripMenuItem,
            this.setSpecialToolStripMenuItem,
            this.clearAllFilteredToolStripMenuItem,
            this.clearSpecialToolStripMenuItem,
            this.assignToGroupToolStripMenuItem});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(164, 114);
            this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
            // 
            // setFIlteredToolStripMenuItem
            // 
            this.setFIlteredToolStripMenuItem.Name = "setFIlteredToolStripMenuItem";
            this.setFIlteredToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
            this.setFIlteredToolStripMenuItem.Text = "Set Filtered";
            this.setFIlteredToolStripMenuItem.Click += new System.EventHandler(this.setFIlteredToolStripMenuItem_Click);
            // 
            // setSpecialToolStripMenuItem
            // 
            this.setSpecialToolStripMenuItem.Name = "setSpecialToolStripMenuItem";
            this.setSpecialToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
            this.setSpecialToolStripMenuItem.Text = "Set Special";
            this.setSpecialToolStripMenuItem.Click += new System.EventHandler(this.setSpecialToolStripMenuItem_Click);
            // 
            // clearAllFilteredToolStripMenuItem
            // 
            this.clearAllFilteredToolStripMenuItem.Name = "clearAllFilteredToolStripMenuItem";
            this.clearAllFilteredToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
            this.clearAllFilteredToolStripMenuItem.Text = "Clear Filtered";
            this.clearAllFilteredToolStripMenuItem.Click += new System.EventHandler(this.clearAllFilteredToolStripMenuItem_Click);
            // 
            // clearSpecialToolStripMenuItem
            // 
            this.clearSpecialToolStripMenuItem.Name = "clearSpecialToolStripMenuItem";
            this.clearSpecialToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
            this.clearSpecialToolStripMenuItem.Text = "Clear Special";
            this.clearSpecialToolStripMenuItem.Click += new System.EventHandler(this.clearSpecialToolStripMenuItem_Click);
            // 
            // assignToGroupToolStripMenuItem
            // 
            this.assignToGroupToolStripMenuItem.Name = "assignToGroupToolStripMenuItem";
            this.assignToGroupToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
            this.assignToGroupToolStripMenuItem.Text = "Assign To Group";
            // 
            // tpHighlights
            // 
            this.tpHighlights.Controls.Add(this.slvHighlights);
            this.tpHighlights.Controls.Add(this.panel4);
            this.tpHighlights.Controls.Add(this.panel3);
            this.tpHighlights.Location = new System.Drawing.Point(4, 22);
            this.tpHighlights.Name = "tpHighlights";
            this.tpHighlights.Size = new System.Drawing.Size(693, 323);
            this.tpHighlights.TabIndex = 5;
            this.tpHighlights.Text = "Highlights";
            this.tpHighlights.UseVisualStyleBackColor = true;
            // 
            // slvHighlights
            // 
            this.slvHighlights.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.chColor,
            this.chVisible,
            this.chDisplay,
            this.chName});
            this.slvHighlights.Dock = System.Windows.Forms.DockStyle.Fill;
            this.slvHighlights.FullRowSelect = true;
            this.slvHighlights.HideSelection = false;
            this.slvHighlights.Location = new System.Drawing.Point(0, 32);
            this.slvHighlights.MultiSelect = false;
            this.slvHighlights.Name = "slvHighlights";
            this.slvHighlights.Size = new System.Drawing.Size(693, 267);
            this.slvHighlights.TabIndex = 2;
            this.slvHighlights.UseCompatibleStateImageBehavior = false;
            this.slvHighlights.View = System.Windows.Forms.View.Details;
            this.slvHighlights.SLVDrawItem += new SharpListView.SharpListView.DrawItemEventHandler(this.slvHighlights_SLVDrawItem);
            this.slvHighlights.SelectedIndexChanged += new System.EventHandler(this.slvHighlights_SelectedIndexChanged);
            // 
            // chColor
            // 
            this.chColor.Text = "Color";
            this.chColor.Width = 41;
            // 
            // chVisible
            // 
            this.chVisible.Text = "Visible";
            this.chVisible.Width = 43;
            // 
            // chDisplay
            // 
            this.chDisplay.Text = "Display";
            this.chDisplay.Width = 98;
            // 
            // chName
            // 
            this.chName.Text = "Name";
            this.chName.Width = 135;
            // 
            // panel4
            // 
            this.panel4.Controls.Add(this.btnDeleteHighlight);
            this.panel4.Controls.Add(this.btnAddHighlight);
            this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel4.Location = new System.Drawing.Point(0, 299);
            this.panel4.Name = "panel4";
            this.panel4.Size = new System.Drawing.Size(693, 24);
            this.panel4.TabIndex = 3;
            // 
            // btnDeleteHighlight
            // 
            this.btnDeleteHighlight.Location = new System.Drawing.Point(200, 3);
            this.btnDeleteHighlight.Name = "btnDeleteHighlight";
            this.btnDeleteHighlight.Size = new System.Drawing.Size(136, 20);
            this.btnDeleteHighlight.TabIndex = 1;
            this.btnDeleteHighlight.Text = "Delete custom highlight";
            this.btnDeleteHighlight.Click += new System.EventHandler(this.btnDeleteHighlight_Click);
            // 
            // btnAddHighlight
            // 
            this.btnAddHighlight.Location = new System.Drawing.Point(2, 3);
            this.btnAddHighlight.Name = "btnAddHighlight";
            this.btnAddHighlight.Size = new System.Drawing.Size(136, 20);
            this.btnAddHighlight.TabIndex = 0;
            this.btnAddHighlight.Text = "Add custom highlight";
            this.btnAddHighlight.Click += new System.EventHandler(this.btnAddHighlight_Click);
            // 
            // panel3
            // 
            this.panel3.Controls.Add(this.tbName);
            this.panel3.Controls.Add(this.cbDisplayText);
            this.panel3.Controls.Add(this.cbVisible);
            this.panel3.Controls.Add(this.cpColor);
            this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel3.Location = new System.Drawing.Point(0, 0);
            this.panel3.Name = "panel3";
            this.panel3.Size = new System.Drawing.Size(693, 32);
            this.panel3.TabIndex = 1;
            // 
            // tbName
            // 
            this.tbName.Location = new System.Drawing.Point(184, 8);
            this.tbName.Name = "tbName";
            this.tbName.Size = new System.Drawing.Size(136, 20);
            this.tbName.TabIndex = 3;
            this.tbName.TextChanged += new System.EventHandler(this.tbName_TextChanged);
            this.tbName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tbName_KeyPress);
            // 
            // cbDisplayText
            // 
            this.cbDisplayText.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbDisplayText.Items.AddRange(new object[] {
            "Nothing",
            "Name",
            "Level",
            "Name+Level",
            "Race+Class",
            "Race+Class+Level"});
            this.cbDisplayText.Location = new System.Drawing.Point(88, 8);
            this.cbDisplayText.Name = "cbDisplayText";
            this.cbDisplayText.Size = new System.Drawing.Size(96, 21);
            this.cbDisplayText.TabIndex = 2;
            this.cbDisplayText.SelectedIndexChanged += new System.EventHandler(this.cbDisplayText_SelectedIndexChanged);
            // 
            // cbVisible
            // 
            this.cbVisible.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbVisible.Items.AddRange(new object[] {
            "Yes",
            "No"});
            this.cbVisible.Location = new System.Drawing.Point(40, 8);
            this.cbVisible.Name = "cbVisible";
            this.cbVisible.Size = new System.Drawing.Size(48, 21);
            this.cbVisible.TabIndex = 1;
            this.cbVisible.SelectedIndexChanged += new System.EventHandler(this.cbVisible_SelectedIndexChanged);
            // 
            // cpColor
            // 
            this.cpColor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.cpColor.Columns = 8;
            this.cpColor.DisplayColorWidth = 18;
            this.cpColor.Location = new System.Drawing.Point(0, 8);
            this.cpColor.Name = "cpColor";
            this.cpColor.Size = new System.Drawing.Size(40, 21);
            this.cpColor.TabIndex = 0;
            this.cpColor.ColorChanged += new PJLControls.ColorChangedEventHandler(this.cpColor_ColorChanged);
            // 
            // tpGeneral
            // 
            this.tpGeneral.Controls.Add(this.nudMinimapRadius);
            this.tpGeneral.Controls.Add(this.label7);
            this.tpGeneral.Controls.Add(this.cbShowMinimap);
            this.tpGeneral.Controls.Add(this.cbStayOnTop);
            this.tpGeneral.Controls.Add(this.panel2);
            this.tpGeneral.Controls.Add(this.tbPort);
            this.tpGeneral.Controls.Add(this.label1);
            this.tpGeneral.Controls.Add(this.label2);
            this.tpGeneral.Controls.Add(this.tbServer);
            this.tpGeneral.Controls.Add(this.cbxFilter);
            this.tpGeneral.Controls.Add(this.cbxRotateMap);
            this.tpGeneral.Location = new System.Drawing.Point(4, 22);
            this.tpGeneral.Name = "tpGeneral";
            this.tpGeneral.Size = new System.Drawing.Size(705, 325);
            this.tpGeneral.TabIndex = 0;
            this.tpGeneral.Text = "General";
            this.tpGeneral.UseVisualStyleBackColor = true;
            // 
            // nudMinimapRadius
            // 
            this.nudMinimapRadius.Location = new System.Drawing.Point(112, 40);
            this.nudMinimapRadius.Name = "nudMinimapRadius";
            this.nudMinimapRadius.Size = new System.Drawing.Size(56, 20);
            this.nudMinimapRadius.TabIndex = 2;
            // 
            // label7
            // 
            this.label7.Location = new System.Drawing.Point(16, 40);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(93, 20);
            this.label7.TabIndex = 33;
            this.label7.Text = "Minimap radius";
            this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // cbShowMinimap
            // 
            this.cbShowMinimap.Location = new System.Drawing.Point(-8, 24);
            this.cbShowMinimap.Name = "cbShowMinimap";
            this.cbShowMinimap.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            this.cbShowMinimap.Size = new System.Drawing.Size(134, 16);
            this.cbShowMinimap.TabIndex = 1;
            this.cbShowMinimap.Text = "Show minimap";
            // 
            // cbStayOnTop
            // 
            this.cbStayOnTop.Location = new System.Drawing.Point(32, 64);
            this.cbStayOnTop.Name = "cbStayOnTop";
            this.cbStayOnTop.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            this.cbStayOnTop.Size = new System.Drawing.Size(94, 16);
            this.cbStayOnTop.TabIndex = 3;
            this.cbStayOnTop.Text = "Stay on top";
            // 
            // panel2
            // 
            this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.panel2.Location = new System.Drawing.Point(0, 88);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(336, 4);
            this.panel2.TabIndex = 30;
            // 
            // tbPort
            // 
            this.tbPort.Location = new System.Drawing.Point(112, 128);
            this.tbPort.Name = "tbPort";
            this.tbPort.Size = new System.Drawing.Size(136, 20);
            this.tbPort.TabIndex = 5;
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(40, 104);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(68, 20);
            this.label1.TabIndex = 26;
            this.label1.Text = "Server";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(40, 128);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(68, 20);
            this.label2.TabIndex = 27;
            this.label2.Text = "Port";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // tbServer
            // 
            this.tbServer.Location = new System.Drawing.Point(112, 104);
            this.tbServer.Name = "tbServer";
            this.tbServer.Size = new System.Drawing.Size(136, 20);
            this.tbServer.TabIndex = 4;
            // 
            // cbxFilter
            // 
            this.cbxFilter.Location = new System.Drawing.Point(132, 8);
            this.cbxFilter.Name = "cbxFilter";
            this.cbxFilter.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            this.cbxFilter.Size = new System.Drawing.Size(94, 16);
            this.cbxFilter.TabIndex = 2;
            this.cbxFilter.Text = "Filter";
            // 
            // cbxRotateMap
            // 
            this.cbxRotateMap.Location = new System.Drawing.Point(32, 8);
            this.cbxRotateMap.Name = "cbxRotateMap";
            this.cbxRotateMap.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            this.cbxRotateMap.Size = new System.Drawing.Size(94, 16);
            this.cbxRotateMap.TabIndex = 2;
            this.cbxRotateMap.Text = "Rotate Map";
            // 
            // tcOptions
            // 
            this.tcOptions.Controls.Add(this.tpGeneral);
            this.tcOptions.Controls.Add(this.tpHighlights);
            this.tcOptions.Controls.Add(this.tbFilter);
            this.tcOptions.Controls.Add(this.tbFocus);
            this.tcOptions.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tcOptions.Location = new System.Drawing.Point(0, 0);
            this.tcOptions.Name = "tcOptions";
            this.tcOptions.SelectedIndex = 0;
            this.tcOptions.Size = new System.Drawing.Size(713, 351);
            this.tcOptions.TabIndex = 6;
            // 
            // tbFocus
            // 
            this.tbFocus.Controls.Add(this.txtFocustTargetQuery);
            this.tbFocus.Controls.Add(this.btnFindFocusTarget);
            this.tbFocus.Controls.Add(this.btnRefreshFocusTargets);
            this.tbFocus.Controls.Add(this.treeView1);
            this.tbFocus.Location = new System.Drawing.Point(4, 22);
            this.tbFocus.Name = "tbFocus";
            this.tbFocus.Padding = new System.Windows.Forms.Padding(3);
            this.tbFocus.Size = new System.Drawing.Size(693, 323);
            this.tbFocus.TabIndex = 7;
            this.tbFocus.Text = "Focus Target";
            this.tbFocus.UseVisualStyleBackColor = true;
            // 
            // txtFocustTargetQuery
            // 
            this.txtFocustTargetQuery.Location = new System.Drawing.Point(131, 9);
            this.txtFocustTargetQuery.Name = "txtFocustTargetQuery";
            this.txtFocustTargetQuery.Size = new System.Drawing.Size(144, 20);
            this.txtFocustTargetQuery.TabIndex = 8;
            this.txtFocustTargetQuery.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox3_KeyUp);
            // 
            // btnFindFocusTarget
            // 
            this.btnFindFocusTarget.Location = new System.Drawing.Point(281, 8);
            this.btnFindFocusTarget.Name = "btnFindFocusTarget";
            this.btnFindFocusTarget.Size = new System.Drawing.Size(79, 20);
            this.btnFindFocusTarget.TabIndex = 7;
            this.btnFindFocusTarget.Text = "Find";
            this.btnFindFocusTarget.UseVisualStyleBackColor = true;
            this.btnFindFocusTarget.Click += new System.EventHandler(this.button6_Click);
            // 
            // btnRefreshFocusTargets
            // 
            this.btnRefreshFocusTargets.Location = new System.Drawing.Point(8, 6);
            this.btnRefreshFocusTargets.Name = "btnRefreshFocusTargets";
            this.btnRefreshFocusTargets.Size = new System.Drawing.Size(75, 23);
            this.btnRefreshFocusTargets.TabIndex = 2;
            this.btnRefreshFocusTargets.Text = "Refresh";
            this.btnRefreshFocusTargets.Click += new System.EventHandler(this.button1_Click);
            // 
            // treeView1
            // 
            this.treeView1.CheckBoxes = true;
            this.treeView1.Location = new System.Drawing.Point(3, 39);
            this.treeView1.Name = "treeView1";
            this.treeView1.Size = new System.Drawing.Size(579, 286);
            this.treeView1.TabIndex = 1;
            this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck);
            // 
            // frmOptions
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(713, 383);
            this.Controls.Add(this.tcOptions);
            this.Controls.Add(this.panel1);
            this.Name = "frmOptions";
            this.Text = "Options";
            this.panel1.ResumeLayout(false);
            this.tbFilter.ResumeLayout(false);
            this.tbFilter.PerformLayout();
            this.contextMenuStrip1.ResumeLayout(false);
            this.tpHighlights.ResumeLayout(false);
            this.panel4.ResumeLayout(false);
            this.panel3.ResumeLayout(false);
            this.panel3.PerformLayout();
            this.tpGeneral.ResumeLayout(false);
            this.tpGeneral.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.nudMinimapRadius)).EndInit();
            this.tcOptions.ResumeLayout(false);
            this.tbFocus.ResumeLayout(false);
            this.tbFocus.PerformLayout();
            this.ResumeLayout(false);

        }

        private void LoadFilters()
        {
            bool flag = this.chkShowHideGroups.Checked;
            this.mInUpdate = true;
            this.lstViewObjects.ListViewItemSorter = null;
            this.mListViewSortManager = new ListViewSortManager(this.lstViewObjects, new System.Type[] { typeof(ListViewInt32Sort), typeof(ListViewTextSort), typeof(ListViewTextSort), typeof(ListViewTextSort), typeof(ListViewTextSort), typeof(ListViewTextSort) });
            this.lstViewObjects.Groups.Clear();
            this.lstViewObjects.Items.Clear();
            if (this.mMain != null)
            {
                foreach (ViewObject obj2 in this.mMain.Objects.Values)
                {
                    if (!Support.filterObjectList.ContainsKey(obj2.key))
                    {
                        Support.filterObjectList.Add(obj2.key, obj2.GetFilterObject());
                    }
                }
            }
            SortedList<string, ListViewGroup> list = null;
            ListViewGroup group = null;
            if (flag)
            {
                list = new SortedList<string, ListViewGroup>();
                group = this.lstViewObjects.Groups.Add("General", "General");
                list.Add("General", group);
            }
            Hashtable hashtable = new Hashtable();
            foreach (FilterObject obj3 in Support.filterObjectList.Values)
            {
                if (obj3.name.Length > 0)
                {
                    ListViewItem item = this.lstViewObjects.Items.Add(obj3.entry.ToString());
                    item.Tag = obj3.key;
                    item.SubItems.Add(obj3.name);
                    item.SubItems.Add(obj3.type);
                    item.SubItems.Add(obj3.typeid);
                    item.SubItems.Add(obj3.filtered.ToString());
                    item.SubItems.Add(obj3.special.ToString());
                    if (flag)
                    {
                        ListViewGroup group2 = null;
                        string key = obj3.group;
                        if (list.ContainsKey(key))
                        {
                            group2 = list[key];
                        }
                        else if (key.Length == 0)
                        {
                            group2 = group;
                        }
                        else
                        {
                            group2 = this.lstViewObjects.Groups.Add(key, key);
                            list.Add(key, group2);
                        }
                        group2.Items.Add(item);
                    }
                    if (obj3.filtered)
                    {
                        item.ForeColor = Color.Red;
                    }
                    else if (obj3.special)
                    {
                        item.ForeColor = Color.Green;
                    }
                }
                else
                {
                    hashtable.Add(obj3.key, null);
                }
            }
            foreach (string str2 in hashtable.Keys)
            {
                Support.filterObjectList.Remove(str2);
            }
            this.lstViewObjects.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.lstViewObjects.Columns[1].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.lstViewObjects.Columns[2].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.lstViewObjects.Columns[3].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.lstViewObjects.Columns[4].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.lstViewObjects.Columns[5].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.mInUpdate = false;
        }

        private void LoadFocused()
        {
            this.treeView1.Nodes.Clear();
            TreeNode node = this.treeView1.Nodes.Add("Players");
            TreeNode node2 = this.treeView1.Nodes.Add("GameObjects");
            TreeNode node3 = this.treeView1.Nodes.Add("Units");
            TreeNode node4 = this.treeView1.Nodes.Add("Dynamic");
            TreeNode node5 = this.treeView1.Nodes.Add("Corpse");
            if (this.mMain != null)
            {
                if (this.mMain.Player != null)
                {
                    TreeNode node6 = node.Nodes.Add(this.mMain.Player.name);
                    node6.Tag = this.mMain.Player.guid;
                    if ((this.mMain.Player.guid == this.mFocusGuid) || (this.mFocusGuid == 0L))
                    {
                        node6.Checked = true;
                    }
                }
                foreach (ViewObject obj2 in this.mMain.Objects.Values)
                {
                    TreeNode node7 = null;
                    TreeNode node8 = null;
                    if (obj2.type == enObjectTypes.Player)
                    {
                        node8 = node;
                    }
                    else if (obj2.type == enObjectTypes.Unit)
                    {
                        node8 = node3;
                    }
                    else if (obj2.type == enObjectTypes.GameObject)
                    {
                        node8 = node2;
                    }
                    else if (obj2.type == enObjectTypes.Dynamic)
                    {
                        node8 = node4;
                    }
                    else if (obj2.type == enObjectTypes.Corpse)
                    {
                        node8 = node5;
                    }
                    if (node8 != null)
                    {
                        node7 = node8.Nodes.Add(obj2.LongName);
                        node7.Tag = obj2.guid;
                        if (obj2.guid == this.mFocusGuid)
                        {
                            node7.Checked = true;
                        }
                    }
                }
            }
        }

        public void LoadSettings(clsSettings settings)
        {
            this.cbStayOnTop.Checked = settings.StayOnTop;
            this.cbxFilter.Checked = settings.Filter;
            this.cbxRotateMap.Checked = settings.RotateMap;
            this.cbShowMinimap.Checked = settings.ShowMinimap;
            this.nudMinimapRadius.Value = settings.MinimapRadius;
            this.tbServer.Text = settings.Server;
            this.tbPort.Text = settings.Port;
            for (int i = 0; i < settings.arrDisplayItems.Count; i++)
            {
                clsDisplayItem item = (clsDisplayItem) settings.arrDisplayItems[i];
                ListViewItem item2 = new ListViewItem();
                item2.Text = item.Color.ToString();
                item2.SubItems.Add(item.Visible ? "Yes" : "No");
                switch (item.DisplayText)
                {
                    case eDisplayText.Nothing:
                        item2.SubItems.Add("Nothing");
                        break;

                    case eDisplayText.OnlyName:
                        item2.SubItems.Add("Name");
                        break;

                    case eDisplayText.OnlyLevel:
                        item2.SubItems.Add("Level");
                        break;

                    case eDisplayText.BothNameAndLevel:
                        item2.SubItems.Add("Name+Level");
                        break;

                    case eDisplayText.RaceAndClass:
                        item2.SubItems.Add("Race+Class");
                        break;

                    case eDisplayText.RaceAndClassAndLevel:
                        item2.SubItems.Add("Race+Class+Level");
                        break;

                    case eDisplayText.Find:
                        item2.SubItems.Add("Find");
                        break;
                }
                item2.Tag = item.Clone();
                item2.SubItems.Add(item.Name);
                this.slvHighlights.Items.Add(item2);
            }
            this.slvHighlights_SelectedIndexChanged(null, null);
        }

        private void lstViewObjects_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            if (!this.mInUpdate)
            {
                this.mInUpdate = true;
                if (e.Item.Checked)
                {
                    e.Item.ForeColor = Color.Red;
                }
                else
                {
                    e.Item.ForeColor = SystemColors.WindowText;
                }
                Support.filterObjectList[(string) e.Item.Tag].filtered = e.Item.Checked;
                this.mInUpdate = false;
            }
        }

        private void lstViewObjects_KeyDown(object sender, KeyEventArgs e)
        {
            this.mInUpdate = true;
            this.mListViewSortManager.Suspend();
            IComparer listViewItemSorter = this.lstViewObjects.ListViewItemSorter;
            this.lstViewObjects.ListViewItemSorter = null;
            if (e.Control & (e.KeyCode == Keys.A))
            {
                foreach (ListViewItem item in this.lstViewObjects.Items)
                {
                    item.Selected = true;
                }
            }
            else if (e.Control & (e.KeyCode == Keys.D))
            {
                foreach (ListViewItem item in this.lstViewObjects.SelectedItems)
                {
                    string tag = (string) item.Tag;
                    item.Remove();
                    Support.filterObjectList.Remove(tag);
                }
            }
            else if (e.Control & (e.KeyCode == Keys.C))
            {
                Clipboard.Clear();
                foreach (ListViewItem item in this.lstViewObjects.SelectedItems)
                {
                    Clipboard.SetText(item.SubItems[1].Text);
                    break;
                }
            }
            else if (e.Control & (e.KeyCode == Keys.E))
            {
                Clipboard.Clear();
                foreach (ListViewItem item in this.lstViewObjects.SelectedItems)
                {
                    Clipboard.SetText(item.SubItems[0].Text);
                    break;
                }
            }
            this.mListViewSortManager.Resume();
            this.lstViewObjects.ListViewItemSorter = listViewItemSorter;
            this.mInUpdate = false;
        }

        public void OnGroupMenueClick(object sender, EventArgs e)
        {
            ToolStripItem item = (ToolStripItem) sender;
            ListViewGroup tag = (ListViewGroup) item.Tag;
            foreach (ListViewItem item2 in this.lstViewObjects.SelectedItems)
            {
                if (item2.Group != null)
                {
                    item2.Group.Items.Remove(item2);
                }
                tag.Items.Add(item2);
                Support.filterObjectList[(string) item2.Tag].group = tag.Name;
            }
        }

        public void SaveSettings(clsSettings settings)
        {
            settings.StayOnTop = this.cbStayOnTop.Checked;
            settings.Filter = this.cbxFilter.Checked;
            Globals.Filter = settings.Filter;
            settings.RotateMap = this.cbxRotateMap.Checked;
            settings.ShowMinimap = this.cbShowMinimap.Checked;
            settings.MinimapRadius = (int) this.nudMinimapRadius.Value;
            settings.Server = this.tbServer.Text;
            settings.Port = this.tbPort.Text;
            settings.arrDisplayItems.Clear();
            foreach (ListViewItem item in this.slvHighlights.Items)
            {
                settings.arrDisplayItems.Add(item.Tag);
            }
        }

        private void setFIlteredToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in this.lstViewObjects.SelectedItems)
            {
                string tag = (string) item.Tag;
                item.SubItems[4].Text = true.ToString();
                Support.filterObjectList[tag].filtered = true;
                item.ForeColor = Color.Red;
            }
        }

        private void setSpecialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in this.lstViewObjects.SelectedItems)
            {
                string tag = (string) item.Tag;
                item.SubItems[5].Text = true.ToString();
                Support.filterObjectList[tag].special = true;
                if (item.ForeColor != Color.Red)
                {
                    item.ForeColor = Color.Green;
                }
            }
        }

        private void slvHighlights_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.slvHighlights.SelectedItems.Count == 0)
            {
                this.cpColor.Enabled = false;
                this.cpColor.Color = Color.Black;
                this.cbVisible.Enabled = false;
                this.cbDisplayText.Enabled = false;
                this.tbName.Tag = 1;
                this.tbName.Text = "";
                this.tbName.Tag = 0;
                this.tbName.Enabled = false;
                this.btnDeleteHighlight.Enabled = false;
                this.diSelected = null;
                this.lviSelected = null;
            }
            else
            {
                this.cpColor.Enabled = true;
                this.cbVisible.Enabled = true;
                this.cbDisplayText.Enabled = true;
                clsDisplayItem tag = (clsDisplayItem) this.slvHighlights.SelectedItems[0].Tag;
                this.cpColor.Color = Color.FromArgb(tag.Color);
                this.cbVisible.SelectedIndex = tag.Visible ? 0 : 1;
                this.cbDisplayText.SelectedIndex = (int) tag.DisplayText;
                this.tbName.Tag = 1;
                this.tbName.Text = tag.Name;
                this.tbName.Tag = 0;
                this.tbName.Enabled = !tag.Name.StartsWith("[") || !tag.Name.EndsWith("]");
                this.btnDeleteHighlight.Enabled = this.tbName.Enabled;
                this.diSelected = tag;
                this.lviSelected = this.slvHighlights.SelectedItems[0];
            }
        }

        private void slvHighlights_SLVDrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < this.slvHighlights.Items.Count)
            {
                ListViewItem item;
                try
                {
                    item = this.slvHighlights.Items[e.Index];
                }
                catch
                {
                    item = null;
                }
                if (item != null)
                {
                    Brush white;
                    if (item.Selected)
                    {
                        e.Graphics.FillRectangle(Brushes.DarkBlue, e.Bounds);
                    }
                    else
                    {
                        e.Graphics.FillRectangle(this.slvHighlights.BkBrush, e.Bounds);
                    }
                    SolidBrush brush = new SolidBrush(Color.FromArgb(int.Parse(item.Text)));
                    Rectangle rectangle = new Rectangle(e.Bounds.X, e.Bounds.Y, this.chColor.Width, e.Bounds.Height);
                    rectangle.Inflate(-2, -2);
                    ControlPaint.DrawBorder3D(e.Graphics, rectangle, Border3DStyle.Flat, Border3DSide.All);
                    rectangle.Inflate(-1, -1);
                    e.Graphics.FillRectangle(brush, rectangle);
                    StringFormat format = new StringFormat();
                    format.FormatFlags = StringFormatFlags.NoWrap;
                    format.Trimming = StringTrimming.EllipsisCharacter;
                    format.Alignment = StringAlignment.Near;
                    if (item.Selected)
                    {
                        white = Brushes.White;
                    }
                    else
                    {
                        white = Brushes.Black;
                    }
                    rectangle = new Rectangle(e.Bounds.X + this.chColor.Width, e.Bounds.Y, this.chVisible.Width, e.Bounds.Height);
                    e.Graphics.DrawString(item.SubItems[1].Text, this.slvHighlights.Font, white, rectangle, format);
                    rectangle = new Rectangle(rectangle.X + rectangle.Width, rectangle.Y, this.chDisplay.Width, rectangle.Height);
                    e.Graphics.DrawString(item.SubItems[2].Text, this.slvHighlights.Font, white, rectangle, format);
                    rectangle = new Rectangle(rectangle.X + rectangle.Width, rectangle.Y, this.chName.Width, rectangle.Height);
                    e.Graphics.DrawString(item.SubItems[3].Text, this.slvHighlights.Font, white, rectangle, format);
                }
            }
        }

        private void tbName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar == '[') || (e.KeyChar == ']'))
            {
                e.Handled = true;
            }
        }

        private void tbName_TextChanged(object sender, EventArgs e)
        {
            if ((this.diSelected != null) && (((int) this.tbName.Tag) == 0))
            {
                this.diSelected.Name = this.tbName.Text;
                this.lviSelected.SubItems[3].Text = this.diSelected.Name;
            }
        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.FindFilter();
            }
        }

        private void textBox3_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.FindFocused();
            }
        }

        private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
        {
            if (!this.mInUpdate)
            {
                this.mInUpdate = true;
                foreach (TreeNode node in this.treeView1.Nodes)
                {
                    foreach (TreeNode node2 in node.Nodes)
                    {
                        if ((node2 != e.Node) && node2.Checked)
                        {
                            node2.Checked = false;
                        }
                    }
                }
                if (e.Node.Checked)
                {
                    this.mFocusGuid = (long) e.Node.Tag;
                }
                this.mInUpdate = false;
            }
        }

        public DialogResult View(clsSettings settings, ViewMain pMain, ref long focusguid)
        {
            this.mFocusGuid = focusguid;
            this.mMain = pMain;
            this.LoadSettings(settings);
            base.ShowDialog();
            focusguid = this.mFocusGuid;
            return base.DialogResult;
        }
    }
}

